package dubrouski.csc;

/**
 * Class represents plane like ax+by+c=z
 * @author Stanislau Dubrouski
 */
class PlaneRepresentor {
    private double aParam;
    private double bParam;
    private double cParam;

    public PlaneRepresentor(double aParam, double bParam, double cParam) {
        this.aParam = aParam;
        this.bParam = bParam;
        this.cParam = cParam;
    }

    public double getaParam() {
        return aParam;
    }

    public double getbParam() {
        return bParam;
    }

    public double getcParam() {
        return cParam;
    }

    public void setaParam(double aParam) {
        this.aParam = aParam;
    }

    public void setbParam(double bParam) {
        this.bParam = bParam;
    }

    public void setcParam(double cParam) {
        this.cParam = cParam;
    }
    
    /*
     * Calculates z in ax+by+c=z equation based on x an y parameters.
     */
    //TODO rename it!
    public float calculateZ(double x, double y){
        return (float) (x*this.getaParam() + y*this.getbParam() + this.getcParam());
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final PlaneRepresentor other = (PlaneRepresentor) obj;
        if (Double.doubleToLongBits(this.aParam) != Double.doubleToLongBits(other.aParam)) {
            return false;
        }
        if (Double.doubleToLongBits(this.bParam) != Double.doubleToLongBits(other.bParam)) {
            return false;
        }
        if (Double.doubleToLongBits(this.cParam) != Double.doubleToLongBits(other.cParam)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 59 * hash + (int) (Double.doubleToLongBits(this.aParam) ^ (Double.doubleToLongBits(this.aParam) >>> 32));
        hash = 59 * hash + (int) (Double.doubleToLongBits(this.bParam) ^ (Double.doubleToLongBits(this.bParam) >>> 32));
        hash = 59 * hash + (int) (Double.doubleToLongBits(this.cParam) ^ (Double.doubleToLongBits(this.cParam) >>> 32));
        return hash;
    }

    @Override
    public String toString() {
        return "z = x * " + this.getaParam() + " + y * " + this.getbParam() + " + " + this.getcParam() + " ";
    }
    
}
